<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/public/base.jspf"%>
<!DOCTYPE html>
<html>
<head>
	<title>属性列表</title>
	<%@include file="/public/base_css.jspf"%>
	<%@include file="/public/base_js.jspf"%>
</head>
<body class="easyui-layout">
	<!-- 数据表格 -->
	<div data-options="region:'west',title:'商品分类',split:true,border:false" style="width:20%;">
		<!-- 类型菜单 -->
		<input id="type_tree_menu"/>
	</div>
	<div data-options="region:'center',title:'商品属性',border:false" style="width: 40%;">
		<!-- 属性列表 -->
		<table id="pro_list"></table>
	</div>
	<div data-options="region:'east',title:'商品属性值',split:true,border:false" style="width:40%;">
		<!-- 属性值列表 -->
		<ul id="proValue_list"></ul>
	</div>
	
</body>
<script type="text/javascript" src="${xpath}/public/js/easyui/plugins/jquery.edatagrid.js"></script>
<script type="text/javascript">

	$('#type_tree_menu').treegrid({
		url:'${xpath}/goodsType/pageList',
        loadFilter:function(data){
        	return data.obj;
        },
        fitColumns:true,
        rownumbers:true,
	    singleSelect:true,
	    fit:true,
        idField:'id',
        treeField:'text',
        columns:[[{
        	title:'名称',
        	field:'text',
        	width:70
        },{
        	title:'属性',
        	field:'id',
        	width:25,
        	align:'center',
        	formatter:function(value,row,index){
        		if(row.parentId!=0){
        			var btn = '<a typeid="'+row.id+'" class="see" href="javascript:void(0);">查看</a>';
        			return btn;
        		}
        		return '';
        	}
        }]],
        onLoadSuccess:function(row,data){
        	//第一条类目下第一条子类目ID
        	loadPro(data[0].children[0].id);
        	$('.see').linkbutton({
        	    iconCls: 'icon-search',
        	    plain: true,
        	    height: 25,
        	    onClick:function(){
        	    	var typeId = $(this).attr('typeid');
        	    	loadPro(typeId);
        	    }
        	});  
        }
	});

	function loadPro(typeId){
		$('#pro_list').edatagrid({
			queryParams:{
				goodsTypeId:typeId
			},
			url:'pageList',
			saveUrl: '',    
		    updateUrl: '',    
		    destroyUrl: '',
			loadFilter:function(data){
	        	return data.obj;
	        },
	        rownumbers:true,
	        pagination:true,
	        idField:'id',
	        fit:true,
	        columns:[[{
	        	title:'属性',
	        	field:'name',
	        },{
	        	title:'用户自定义',
	        	field:'isUserDefined',
	        },{
	        	title:'作为搜索条件',
	        	field:'isShowSelect',
	        },{
	        	title:'修改时间',
	        	field:'editTime',
	        },{
	        	title:'修改时间',
	        	field:'editTime',
	        }]]
		});
	}

	

	function queryPro(typeId){
		
	}
	/*$('#pro_list').treegrid({
		url:'pageList',
        loadFilter:function(data){
        	return data.obj;//jsonbl(data.obj);
        },
        fitColumns:true,
        rownumbers:true,
	    singleSelect:true,
	    pagination:true,
	    fit:true,
        idField:'id',
        treeField:'text',
        toolbar: [{
			iconCls: 'icon-add',
			text:'添加属性',
			handler: function(){add();}
		},'-',{
			iconCls: 'icon-edit',
			text: '修改属性',
			handler: function(){update();}
		},'-',{
			iconCls: 'icon-cancel',
			text: '删除',
			handler: function(){del();}
		}],
        columns:[[{
        	title:'类型名称',
        	field:'text',
        },{
        	title:'创建时间',
        	field:'createTime',
        },{
        	title:'修改时间',
        	field:'editTime',
        }]]
	});

	function add(){
		createWindown('editPage/0','添加类型',320,310);
	}

	function update(){
		createUpdateWindown('datagrid_list','editPage','修改类型',320,310);
	}

	function del(){
		createDelDialog('datagrid_list','manage','删除','确认删除本条数据吗？');
	}*/

</script>
</html>